project(
    'disk-failure-prediction',
    'cpp',
    default_options: [
        'warning_level=3',
        'werror=true',
        'cpp_std=c++20'
    ],
    license: 'Apache-2.0',
    version: '1.0',
    meson_version: '>=0.57.0',
)

sources = [
    'src/prediction-main.cpp',
    'src/disk-prediction.cpp',
]

prediction_headers =  [
     include_directories('include'),
]

###'@OUTPUT0@'
prediction_deps = [
    dependency('phosphor-dbus-interfaces'),
    dependency('phosphor-logging'),
    dependency('sdbusplus'),
    dependency('sdeventplus'),
    dependency('stdplus'),
    dependency('threads'),
]

# CLI11 might not have a pkg-config. It is header only so just make
# sure we can access the needed symbols from the header.
cli11_dep = dependency('cli11', required: false)
has_cli11 = meson.get_compiler('cpp').has_header_symbol(
    'CLI/CLI.hpp',
    'CLI::App',
    dependencies: cli11_dep,
    required: false)
if not has_cli11
    cli11_proj = subproject('cli11', required: false)
    assert(cli11_proj.found(), 'CLI11 is required')
    cli11_dep = cli11_proj.get_variable('CLI11_dep')
endif

executable(
    'disk-failure-prediction',
    sources,
	include_directories: prediction_headers,
#	link_args: ['-lopenbmc_intf' ],
    dependencies: [
        cli11_dep,
        prediction_deps,
    ],
    install: true,
	install_dir: get_option('bindir'),
)
    
systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
    'systemdsystemunitdir',
    define_variable: ['prefix', get_option('prefix')])
       
install_data(
    'disk-failure-prediction.service',
    install_dir: systemd_system_unit_dir
)

#install_data(
#    'discrete_sensor.sh',
#    install_dir: get_option('bindir'),
#    install_mode: 'rwxr-xr-x'
#)
   
